import Vue from "vue";
import Router from "vue-router";

import { setWebViewTitle } from "@/core/mxApi/index";
// import { Toast } from 'vant'
Vue.use(Router);

let router = new Router({
  // mode: 'hash',
  // mode: 'history',  //去掉url中的#
  // base: process.env.BASE_URL,
  routes: [
    // 新雷达图模块
    // {
    //   path: "/",
    //   name: "Radarmap",
    //   component: () => import("./views/Radarmap/index.vue"),
    //   meta: {
    //     name: "科技部CMDB",
    //     keepAliveIndex: true
    //   }
    // },
    {
      path: "/",
      name: "index",
      component: () => import("./views/index.vue"),
      meta: {
        name: "科技部CMDB",
        keepAliveIndex: true,
      },
    },
    //项目经理
    {
      path: "/project",
      name: "project",
      component: () => import("./views/project/index.vue"),
      meta: {
        name: "科技部CMDB",
        keepAliveIndex: true,
      },
    },
    //排行榜
    {
      path: "/RankingList",
      name: "RankingList",
      component: () => import("./views/RankingList/index.vue"),
      meta: {
        name: "排行榜",
        keepAliveIndex: true,
      },
    },
    {
      path:"/echartsone",
      name: "echartsone",
      component:()=>import("./views/Echarts/EchartsOne.vue"),
      meta: {
        name: "科技部CMDB",
        keepAliveIndex: true,
      },
    }
  ],
});

router.afterEach((to, from, next) => {
  // 设置顶部标题
  to.query.title
    ? setWebViewTitle(to.query.title)
    : setWebViewTitle(to.meta.name);
  // 重置滚动条
  window.scrollTo(0, 0);
});

export default router;
